package cn.le.beans.vo;


import cn.le.enums.EApiStatus;

/**
 * 消息生产工厂类
 * Created by wjm on 2017/5/8.
 */
public class ResponseFactory {


    /**
     * 正常消息
     * @param obj
     * @return
     */
    public static ResposeVO ok(Object obj){
        ResposeVO vo = new ResposeVO();
        vo.setData(obj);
        vo.setMessage(EApiStatus.SUCCESS.getMessage());
        vo.setStatus(EApiStatus.SUCCESS.getStatus());

        return vo;
    }


    /**
     * 错误消息
     * @param obj 消息体data
     * @param status 状态关联 EApiStatus
     * @return
     */
    public static ResposeVO err(Object obj, EApiStatus status){
        ResposeVO vo = new ResposeVO();
        vo.setData("");
        vo.setMessage(String.valueOf(obj));
        vo.setStatus(status.getStatus());

        return vo;
    }
}
